//package com.navi.loaddata;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import redis.clients.jedis.JedisPool;
//import redis.clients.jedis.JedisPoolConfig;
//
//import java.time.Duration;
//
///**
// * Created by admin on 2017/6/15.
// */
//@Configuration
//public class RedisConfiguration {
//    @Bean
//    @Autowired
//    public JedisPool jedisPool(@Qualifier("jedis.pool.config") JedisPoolConfig config,
//                               @Value("${jedis.pool.host}") String host,
//                               @Value("${jedis.pool.port}") int port) {
////        , @Value("${jedis.pool.waitTimeout}") int timeout
//        return new JedisPool(config, host, port, 60000);
//    }
//
//    @Bean(name = "jedis.pool.config")
//    public JedisPoolConfig jedisPoolConfig(@Value("${jedis.pool.config.maxTotal}") int maxTotal,
//                                           @Value("${jedis.pool.config.maxIdle}") int maxIdle,
//                                           @Value("${jedis.pool.config.maxWaitMillis}") int maxWaitMillis) {
//        JedisPoolConfig poolConfig = new JedisPoolConfig();
//        poolConfig.setMaxTotal(maxTotal);
//        poolConfig.setMaxIdle(maxIdle);
//        poolConfig.setMaxWaitMillis(maxWaitMillis);
//
//        poolConfig.setTestOnBorrow(true);
//        poolConfig.setTestOnReturn(true);
//        poolConfig.setTestWhileIdle(true);
//
//        poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis());
//        poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis());
//
//        poolConfig.setNumTestsPerEvictionRun(3);
//        poolConfig.setBlockWhenExhausted(true);
//
//        return poolConfig;
//    }
//}
